GBML manual / Queues

queue_empty

True if target currently holds no items, false otherwise. The way to know, BEFORE calling queue_pop/queue_peek, whether the value they would give back is a real item or just the empty-container default.

Syntax

queue_empty(target) -> bool

Arguments

NameType
targetqueue

Returns

bool

Description

true if target currently holds no items, false otherwise. The same answer as queue_length(target) == 0, spelled as its own question.

This is the way to know, BEFORE calling queue_pop/queue_peek, whether the value either would give back is a real item or just the empty-container default - useful anywhere the difference matters (a spawner that should idle once nothing is left queued, say).

Example

/// @type {queue<int>}
/// @capacity 4
var turn_order = [];
var nothing_queued = queue_empty(turn_order); // true
queue_push(turn_order, 1);
var has_next = queue_empty(turn_order); // false
A real capture - an empty queue, queue_empty answering YESA real capture - an empty queue, queue_empty answering YES
A real capture - an empty queue, queue_empty answering YES
The same queue after queue_push(turn_order, 1) - queue_empty now answers NOThe same queue after queue_push(turn_order, 1) - queue_empty now answers NO
The same queue after queuepush(turnorder, 1) - queue_empty now answers NO

On the GBA

Just the deque's empty() - O(1).

See also: queue_popqueue_peekqueue_lengthqueue_pushData containers